package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.VoDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.SubmitNewsTwoService;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("api/v1/news")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;
    @Autowired
    private SubmitNewsTwoService submitNewsTwoService;

    @PostMapping("/list")
    public ResponseResult getNew(@RequestBody WmNewsPageReqDto wmNewsPageReqDto){
        return wmNewsService.getNew(wmNewsPageReqDto);
    }

//    @PostMapping("/submit")
//    public ResponseResult submitNews(@RequestBody WmNewsDto wmNewsDto){
//        return wmNewsService.submitNews(wmNewsDto);
//    }

    @PostMapping("/submit")
    public ResponseResult submitNewsTwo(@RequestBody WmNewsDto wmNewsDto){
        return submitNewsTwoService.submitNewsTwo(wmNewsDto);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return wmNewsService.downOrUp(dto);
    }

    @PostMapping("/list_vo")
    public ResponseResult getList(@RequestBody VoDto voDto){
        return wmNewsService.getList(voDto);
    }

    @GetMapping("/one_vo/{id}")
    public ResponseResult news(@PathVariable Integer id){
        return wmNewsService.getNewOne(id);
    }

    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody Map<String,Object> map){
        return wmNewsService.authFail(map);
    }

    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody Map<String,Object> map){
        return wmNewsService.authPass(map);
    }

}
